home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / ka9q / kit_src / addlin.c next >
Encoding:
C/C++ Source or Header  |  1992-09-03  |  2.4 KB  |  108 lines

  1. /*    (C) Copyright 1991 Dave Fritsche (wb8zxu), All Rights Reserved.
  2.  * 
  3.  *    Redistribution and use in source and binary forms are permitted for
  4.  *    non-commercial use, provided that the above copyright notice and this
  5.  *    paragraph are duplicated in all such forms.  THIS SOFTWARE IS PROVIDED
  6.  *    ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
  7.  *    WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
  8.  *    FITNESS FOR A PARTICULAR PURPOSE.
  9.  */
  10. /*bdoc
  11.  *    Function "ADDLIN"
  12.  *
  13.  *    Written:  Dave Fritsche
  14.  *    Date:  January, 1991
  15.  *
  16.  *    SYNTAX:
  17.  *        addlin(bx, y, ex, type)
  18.  *    where "bx" is the beginning column number to start the line, "y" is
  19.  *    the line number on which to draw the line, and "ex" is the ending
  20.  *    column number for the line.
  21.  *    Type one is a wide, solid line type.  Type
  22.  *    two is dual thin lines, type three is a single thin line, type
  23.  *    four is composed of standard ascii characters: '+', '-', and '|', and
  24.  *    type five writes spaces (to clear a line).
  25.  edoc*/
  26.  
  27. #include <stdio.h>
  28.  
  29. #define BIOS
  30.  
  31. #ifdef BIOS
  32. extern char attrib;
  33. #endif
  34.  
  35. addlin(bx, y, ex, type)
  36. int bx, y, ex, type;
  37. {
  38.     int left, right, line;
  39.     int n;
  40. #ifdef BIOS
  41.     int attr;
  42. #endif
  43.  
  44.     switch (type)
  45.     {
  46.     case 1:
  47.         left = 0xdd;
  48.         right = 0xde;
  49.         line = 0xdb;
  50.         break;
  51.     case 2:
  52.         left = 0xcc;
  53.         right = 0xb9;
  54.         line = 0xcd;
  55.         break;
  56.     case 3:
  57.         left = 0xc3;
  58.         right = 0xb4;
  59.         line = 0xc4;
  60.         break;
  61.     case 5:
  62.         left = right = line = ' ';
  63.         break;
  64.     case 4:
  65.     default:
  66.         left = '+';
  67.         right = '+';
  68.         line = '-';
  69.         break;
  70.     }
  71.  
  72.     if (bx > 80) bx = 80;
  73.     if (y > 25) y = 25;
  74.     if (bx < 1 ) bx =  1;
  75.     if (y < 1 ) y =  1;
  76.     if (ex > 80) ex = 80;
  77.     if (ex < 1 ) ex =  1;
  78.  
  79. #ifndef BIOS
  80. #ifdef CPRINTF
  81.     cprintf("%c[%d;%dH%c", 27, y, bx, left);
  82.     cprintf("%c[%d;%dH%c", 27, y, ex, right);
  83.     for (n = bx+1; n < ex; n++)
  84.         cprintf("%c", line);
  85. #else
  86.     printf("%c[%d;%dH%c", 27, y, bx, left);
  87.     printf("%c[%d;%dH%c", 27, y, ex, right);
  88.     for (n = bx+1; n < ex; n++)
  89.         printf("%c", line);
  90. #endif
  91. #else
  92.     attr = 7;
  93.     if ((attrib & 0x01) != 0)        /* Bold */
  94.         attr |= 0x08;
  95.     if ((attrib & 0x18) != 0)        /* Blink */
  96.         attr |= 0x80;
  97.     if ((attrib & 0x20) != 0)        /* Reverse video */
  98.     {
  99.         attr &= 0xf8;
  100.         attr |= 0x70;
  101.     }
  102.  
  103.     wrbiosch(y-1, bx-1, left, 1, attr);    /* left side */
  104.     wrbiosch(y-1, ex-1, right, 1, attr);    /* right side */
  105.     wrbiosch(y-1, bx, line, ex-bx-1, attr);    /* line */
  106. #endif
  107. }
  108.